﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace yichu_front
{
    public partial class Form修改密码 : Form
    {
        public Form修改密码()
        {
            InitializeComponent();
        }

        private void button确定_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBox新密码.Text.Trim()) == false)
            {
                Pub.user.密码 = textBox新密码.Text.Trim();
                Pub.user.MD5密码 = Util.MySecurity.GetMD5(textBox新密码.Text.Trim());
                int r = SqlSugarHelp.scope.Updateable(Pub.user)
                                          .UpdateColumns(it => new { it.密码, it.MD5密码 }).ExecuteCommand();
                if (r > 0) 
                {
                    MessageBox.Show("修改成功");
                    textBox新密码.Text = "";
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            else
            {
                MessageBox.Show("密码不能为空");
            }
        }
    }
}
